package com.hezhiqin.formework.aop.aspect;

import com.hezhiqin.formework.aop.intercept.HZQMethodInterceptor;
import com.hezhiqin.formework.aop.intercept.HZQMethodInvocation;

import java.lang.reflect.Method;

/**
 * @program: homeWork
 * @description:
 * @author: hezhiqin
 * @create: 2019-11-06 15:58
 */
public class HZQMethodBeforeAdviceInterceptor extends HZQAbstractAspectAdvice  implements HZQMethodInterceptor {

    private HZQJoinPoint joinPoint;

    public HZQMethodBeforeAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }


    private void before(Method method,Object[] args,Object target) throws Throwable{
        super.invokeAdviceMethod(this.joinPoint,null,null);

    }

    @Override
    public Object invoke(HZQMethodInvocation invocation) throws Throwable {
        this.joinPoint = invocation;
        before(invocation.getMethod(), invocation.getArguments(), invocation.getThis());
        return invocation.proceed();
    }
}
